import java.util.Arrays;

public class Solution724 {
    public int pivotIndex(int[] nums) {
        int sum=Arrays.stream(nums).sum();
        int cur=0;
        for (int i=0;i<nums.length;i++){
            if ((sum-nums[i])%2==0 && (sum-nums[i])/2==cur){
                return i;
            }else{
                cur=cur+nums[i];
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        System.out.println(new Solution724().pivotIndex(new int[]{1,7,3,6,5,6}));
    }
}
